# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.
#
# taken from AUR, adapted to our style.
#
# Old Contributor: Ivan Shapovalov <intelfx@intelfx.name>
# Old Contributor: Alexander F. Rødseth <xyproto@archlinux.org>
# Old Contributor: fanningert <thomas@fanninger.at>
#
# Package renamed the 13-05-2021 to avoid issues with the new "glide" package
# included in the official ArchLinux repos.

pkgname=golang-glide
pkgname_bin=glide-go
pkgver=1093.b94b39d
pkgrel=1
pkgdesc='Vendor Package Management for Golang.'
arch=('x86_64' 'aarch64')
url='https://github.com/Masterminds/glide'
license=('MIT')
makedepends=('git' 'go')
source=("$pkgname::git+https://github.com/Masterminds/glide.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

build() {
  cd $pkgname

  GOPATH="$srcdir" go mod init go.mod
  GOPATH="$srcdir" go mod tidy
  GOPATH="$srcdir" go mod download
  GOPATH="$srcdir" go build \
    -trimpath \
    -buildmode=pie \
    -mod=readonly \
    -modcacherw \
    -ldflags "-s -w -X main.version=$pkgver-git" \
    -o $pkgname_bin .
}

package() {
  cd $pkgname

  install -Dm 755 $pkgname_bin "$pkgdir/usr/bin/$pkgname_bin"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" *.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

